<script setup>
  import { ref, onMounted } from 'vue'
  import msgApi from '@/apis/message.js'
  // 1.0 准备数组
  const list = ref([])
  onMounted(() => {
    getList()
  })

  // 2.0 请求服务器获取列表数据
  // contentType = 200:司机端公告数据获取
  async function getList(contentType = 200) {
    let { code, msg, data } = await msgApi.list(contentType)
    if (code != 200) {
      return uni.utils.toast(msg)
    }
    list.value = data.items
    console.log(list.value)
    try {
    } catch (err) {}
  }
</script>
<template>
  <scroll-view class="scroll-view" refresher-enabled scroll-y>
    <view class="scroll-view-wrapper">
      <view class="message-action">
        <text class="iconfont icon-clear"></text>
        全部已读
      </view>
      <uni-list :border="false">
        <uni-list-item
          v-for="item in list"
          :key="item.id"
          to="/subpkg_message/content/index"
          ellipsis="1"
          :title="item.title"
          :rightText="item.created"
        >
          <template v-slot:header>
            <text v-if="item.isRead === 0" class="dot"></text>
          </template>
        </uni-list-item> </uni-list
    ></view>
  </scroll-view>
</template>

<style lang="scss" scoped>
  @import './styles.scss';
</style>
